
//初始化选择
function initSelect(){
	$('select[defValue]').each(function(idx,item){
		$(this).find('option[value="'+$(this).attr('defValue')+'"]').attr('selected','selected');
	});
}

$("[rel=tooltip]").tooltip();
$(function() {
    $('.demo-cancel-click').click(function(){return false;});
});

//消息提示检测
$(function(){
	var msg_status = $('#msg_status').val();
	if(msg_status=='success'){
		$('#msg_tip').modal('show');
	}
	if(msg_status=='error'){
		$('#msg_tip .modal-body').css('color','red');
		$('#msg_tip').modal('show');
	}
});

//确认弹出框
var comfirm_dialog_url;
var $comfirm_data;
var comfirm_isDelete;
 $(function(){
	 $('a[href=#comfirm_dialog]').click(function(){
		 $comfirm_data = $(this).parent().parent();
		 comfirm_dialog_url = $(this).attr("url");
		 comfirm_isDelete = $(this).attr("delete");
		 $('#comfirm_dialog #comfirm_dialog_msg').text($(this).attr('msg'));
	 });
	 $('#comfirm_dialog_ok').click(function(){
		 $.getJSON(comfirm_dialog_url, function(result){
			 var msg_status = result.status;
			 var msg = result.msg;
			 $('#msg_msg').text(msg);
			 if(msg_status=='success'){
	        		$('#msg_tip').modal('show');
	        		if(comfirm_isDelete=='delete'){
	        			$comfirm_data.hide('slow');
	        		}
	        	}
	        	if(msg_status=='error'){
	        		$('#msg_tip .modal-body').css('color','red');
	        		$('#msg_tip').modal('show');
	         }
		 });
	 });
 });